function [distance] = GetDistances(graph)
% Computes shortest distances between all vertices in (graph)
order = max(size(graph));
distance = zeros(order);

temp = graph;
numZeros = order*order;
length = 1;

while (numZeros > 0)
    % Computes total number of cells where the number of paths
    % of up to length("length") is still zero
    numZeros = sum(sum(temp == 0));
    
    % If a cell has a distance value, and didn't before, record
    % "length" as the intervening distance
    for i=1:order
        for j=1:order
            if (distance(i,j) == 0 && temp(i,j) ~= 0)
                distance(i,j) = length;
            end
        end
    end
    
    % increment search length
    temp = temp * graph;
    length = length + 1;
end

%HeatMap(distance)